#ifndef COUNTER_H
#define COUNTER_H

#include <QObject>
#include <QTimer>

class Counter : public QObject
{
    Q_OBJECT
    Q_PROPERTY(int count READ count WRITE setCount NOTIFY countChanged)
    Q_PROPERTY(bool running READ running WRITE setRunning NOTIFY runningChanged)

public:
    explicit Counter(QObject *parent = nullptr);

    int count() const;
    void setCount(int newCount);

    bool running() const;
    void setRunning(bool newRunning);

    Q_INVOKABLE void start();
    Q_INVOKABLE void stop();
    Q_INVOKABLE void reset();

signals:
    void countChanged();
    void runningChanged();
    void showMessage(const QString &message);

private slots:
    void updateCount();

private:
    int m_count;
    bool m_running;
    QTimer *m_timer;
};

#endif // COUNTER_H